
from typing import List


def sortArrayByParityII(nums: List[int]) -> List[int]:
    n = len(nums)
    res = [0]*n 
    slow = 0
    fast = 1
    for num in nums:
        if num%2 == 0:
            res[slow] = num
            slow +=2
        else:
            res[fast] = num
            fast +=2
    return res